Popular Searches
Popular Course Categories
Popular Courses

Working with Excel and SQL Data

Working with Excel and SQL Data

Tableau Integration and Advanced Features

Working with Excel and SQL Data in Tableau

Course: Tableau Training

Topic: Connecting Excel and SQL Data, Data Preparation, Relationships, Joins, Calculations, and Visualization

Explore the course: Explore Tableau Training

Book a demo: Register for a Tableau Course Demo


1. Introduction to Working with Excel and SQL Data

Tableau is a business intelligence and data visualization platform that helps users connect to different data sources, analyze information, and create interactive dashboards. Excel and SQL databases are two commonly used sources for Tableau reporting.

Excel is often used to store structured information in spreadsheets, such as sales reports, customer lists, budgets, and monthly performance records. SQL databases store structured data in tables and are commonly used by business applications to manage large amounts of information.

Tableau can connect to Excel files and supported SQL databases so users can explore data, create visualizations, and combine information from different sources. For example, a company may store sales transactions in SQL Server and maintain sales targets in an Excel workbook. Tableau can use both sources to compare actual sales with planned targets.

Example business scenario

A retail company maintains the following information:

  • Daily sales transactions in a SQL database.
  • Product information in an Excel spreadsheet.
  • Monthly sales targets in another Excel sheet.
  • Regional performance information in a database table.

Tableau can connect to the relevant sources, combine the data using appropriate relationships or joins, and create a dashboard displaying revenue, profit, sales targets, and regional performance.

Excel Files                 SQL Database
(Product / Targets)         (Sales / Customers)
       |                           |
       |                           |
       +------------+--------------+
                    |
                    v
               Tableau
                    |
                    v
        Data Preparation and Modeling
                    |
                    v
          Worksheets and Dashboards
                    |
                    v
          Business Insights and Reports

Official documentation: Plan and Manage a Tableau Data Source.


2. Learning Objectives

After completing these notes, you should be able to:

  • Understand how Tableau works with Excel and SQL data.
  • Connect Excel workbooks to Tableau Desktop.
  • Connect Tableau to supported SQL databases.
  • Understand worksheets, tables, fields, records, and data types.
  • Clean and prepare Excel and SQL data for analysis.
  • Understand relationships, joins, unions, and data blending.
  • Choose between live connections and extracts.
  • Write basic SQL queries for reporting.
  • Create calculated fields and common business metrics.
  • Combine Excel and SQL information for dashboards.
  • Troubleshoot connection, data quality, and performance issues.
  • Build a practical sales dashboard using Excel and SQL data.

3. Understanding Excel Data

Microsoft Excel is a spreadsheet application that stores data in workbooks. A workbook can contain multiple worksheets, tables, and named ranges. Tableau can connect to supported Excel files and use their structured data for analysis.

3.1 What is an Excel workbook?

An Excel workbook is a file that contains one or more worksheets. Common Excel file extensions include:

  • .xlsx — modern Excel workbook format.
  • .xls — older Excel workbook format.
  • .xlsm — Excel workbook that can contain macros; compatibility and behavior should be checked for the intended workflow.

3.2 What is a worksheet?

A worksheet is a grid of rows and columns inside an Excel workbook. Each row generally represents a record, while each column represents a field or attribute.

Example Excel sales data

Order ID Order Date Product Region Quantity Sales
1001 2026-01-05 Laptop Mumbai 2 90000
1002 2026-01-08 Monitor Delhi 3 45000
1003 2026-01-12 Keyboard Pune 5 7500
1004 2026-02-02 Laptop Mumbai 1 45000

In this dataset, each row represents an order record. Fields such as Order ID, Order Date, Product, Region, Quantity, and Sales describe that record.

3.3 Best practices for Excel data

  • Use one clear header row with meaningful column names.
  • Keep one record per row.
  • Avoid merged cells in the data range.
  • Do not place subtotals or decorative headings inside the main data table.
  • Use consistent formats for dates, numbers, currencies, and identifiers.
  • Remove unnecessary blank rows and columns.
  • Check for duplicate records and missing values.
  • Convert structured ranges to Excel tables when appropriate.
  • Use unique and descriptive worksheet names.
  • Keep the source file in a stable location when a recurring connection depends on it.

4. Connecting Excel Data to Tableau

Tableau provides an Excel connector for supported .xls and .xlsx files. The connector allows Tableau to use worksheets, Excel tables, and named ranges as data tables.

Step-by-step procedure

  1. Open Tableau Desktop.
  2. On the Start page, locate the Connect section.
  3. Select Microsoft Excel.
  4. Browse to the Excel workbook you want to analyze.
  5. Select the file and click Open.
  6. Review the Data Source page.
  7. Drag the required worksheet or Excel table to the data model canvas if it is not already selected.
  8. Review the data preview and verify the field names and data types.
  9. Rename the Tableau data source if necessary.
  10. Open a worksheet and begin creating visualizations.

Example

Suppose the workbook is named Retail_Sales.xlsx and contains a worksheet called Sales_Data. After connecting to the workbook, select the relevant worksheet and use fields such as Region, Product, Order Date, and Sales to build a chart.

Important Excel connection considerations

  • Tableau may interpret a worksheet, named range, or Excel table as a table in the data source.
  • When Excel tables contain headers, Tableau can use those headers as field names.
  • Incorrectly formatted columns may be interpreted as the wrong data type.
  • Excel pivot tables are not supported by the standard Excel connector as ordinary source tables; use an appropriate underlying data range or another supported approach.
  • For recurring reports, check that the workbook remains available and that the expected structure does not change unexpectedly.

Official documentation: Connect Tableau to Microsoft Excel.


5. Understanding SQL Data

SQL stands for Structured Query Language. It is used to query and manage data stored in relational database systems. SQL databases organize data into tables consisting of rows and columns.

5.1 What is a database?

A database is an organized collection of information. A retail database may contain separate tables for orders, customers, products, payments, and employees.

5.2 What is a table?

A table stores related information in rows and columns. For example, an Orders table stores order records, while a Customers table stores customer details.

5.3 What is a row?

A row represents one record in a table. In an Orders table, a row may represent one order or one order line, depending on the database design.

5.4 What is a column?

A column represents a field or attribute, such as Customer ID, Order Date, Product ID, Quantity, or Sales Amount.

Example SQL Orders table

OrderID CustomerID OrderDate Region SalesAmount
501 C101 2026-01-05 Mumbai 90000
502 C102 2026-01-08 Delhi 45000
503 C103 2026-01-12 Pune 7500
504 C101 2026-02-02 Mumbai 45000

5.5 Common SQL database systems

  • Microsoft SQL Server
  • MySQL
  • PostgreSQL
  • Oracle Database
  • Snowflake
  • Amazon Redshift
  • Google BigQuery

Tableau supports many database connectors. The exact connector, authentication method, driver requirements, and connection capabilities depend on the database and Tableau environment.


6. Connecting SQL Data to Tableau

Tableau can connect to supported SQL databases to analyze information stored in database tables or views. Depending on the connector and environment, the connection may use a live connection or an extract.

Step-by-step procedure

  1. Open Tableau Desktop.
  2. Under Connect, choose the appropriate database connector, such as Microsoft SQL Server or PostgreSQL.
  3. Enter the database server name or host address.
  4. Enter the required database or other connection details.
  5. Choose the approved authentication method.
  6. Enter credentials if required and permitted by your organization's security policy.
  7. Connect to the database.
  8. Select the relevant database, schema, tables, or views.
  9. Drag the required table to the data model canvas.
  10. Inspect the preview, field names, data types, and relationships.
  11. Select the appropriate connection mode when the connector supports the choice.
  12. Open a worksheet and start analyzing the data.

Example

Suppose a company stores transactions in a Microsoft SQL Server database named RetailDB. Its Orders table contains OrderID, CustomerID, OrderDate, Region, and SalesAmount. Tableau can connect to the database and use these fields to create revenue reports and regional performance dashboards.

Connection information commonly required

Information Purpose
Server or host Identifies the database server.
Database name Identifies the database to access.
Authentication method Determines how the user or service proves its identity.
Username and password Used when the configured authentication method requires them.
Driver or connector Provides the necessary communication between Tableau and the database.
Network access Ensures Tableau can reach the database endpoint.

Security reminder: Use approved credentials and grant only the database access needed for reporting. Never paste passwords into public documents, workbook descriptions, or unsecured scripts.


7. Understanding Data Types in Excel and SQL

Data types define the kind of values a field contains. Correct data types are essential for calculations, sorting, filtering, relationships, joins, and visualizations.

Data Type Example Typical Use
String / Text Product Name, Region Labels, categories, identifiers stored as text.
Integer Quantity = 10 Counts and whole-number measurements.
Decimal / Number Sales = 12500.75 Revenue, cost, profit, and measurements.
Date 2026-01-15 Order dates, joining dates, and calendar analysis.
DateTime 2026-01-15 10:30:00 Timestamps and time-based event analysis.
Boolean True / False Conditions and status flags.
Geographic City, State, Country Maps and spatial analysis when correctly assigned.

Changing data types in Tableau

  1. Open the Data Source page or worksheet.
  2. Locate the field in the data preview or Data pane.
  3. Select the data type icon beside the field name.
  4. Choose the correct type.
  5. Validate the resulting values and calculations.

Common data type mistakes

  • Storing a date as a string.
  • Importing numeric values containing inconsistent symbols or text.
  • Storing customer IDs as numbers when leading zeros are meaningful.
  • Trying to join a text field to a numeric field without standardizing them.
  • Using inconsistent date formats across different Excel files.

When fields are used to join tables, ensure that the corresponding fields have compatible data types and represent the same business concept.


8. Data Cleaning and Preparation

Data cleaning is the process of identifying and correcting issues that can affect analysis. Excel files and SQL tables may contain missing values, duplicate records, inconsistent naming, incorrect data types, and invalid values.

8.1 Common data quality issues

  • Missing customer IDs.
  • Duplicate order records.
  • Different spellings of the same region.
  • Incorrect date formats.
  • Numbers stored as text.
  • Extra spaces in field values.
  • Inconsistent product names.
  • Incorrect or incomplete join keys.

8.2 Example of inconsistent data

Original Region Value Potential Issue Standardized Value
Mumbai Consistent value Mumbai
mumbai Different capitalization Mumbai
Mumbai Trailing space Mumbai
MUMBAI Different capitalization Mumbai

8.3 Recommended cleaning procedure

  1. Inspect the source data before building visualizations.
  2. Check column names and field meanings.
  3. Identify missing values and duplicates.
  4. Standardize date, numeric, and text formats.
  5. Verify primary keys and relationships.
  6. Correct inconsistent categories where appropriate.
  7. Check whether transformations change record counts or totals.
  8. Compare important figures against the original source.

For complex data cleaning and repeatable preparation workflows, consider using Tableau Prep or an appropriate upstream data preparation process.


9. Combining Excel and SQL Data in Tableau

Tableau can use multiple connections within a data source, allowing compatible data from different sources to be combined. For example, a company can combine sales data from SQL Server with sales targets from Excel.

Example datasets

SQL Orders table:

OrderID Region Sales
101 Mumbai 50000
102 Delhi 40000
103 Pune 30000

Excel Targets table:

Region Sales Target
Mumbai 60000
Delhi 45000
Pune 35000

By connecting both sources and relating them through the Region field, Tableau can help compare actual sales with targets. The model must be designed carefully so that target values are not multiplied when multiple orders exist for the same region.

General procedure

  1. Connect to the SQL database.
  2. Add the relevant Orders table to the Tableau data source.
  3. Under Connections, choose Add to create an additional connection.
  4. Select Microsoft Excel and connect to the targets workbook.
  5. Drag the Targets table onto the data model canvas.
  6. Define the relationship using the matching Region fields.
  7. Check field types and data values on both sides.
  8. Create a worksheet showing actual sales and sales targets.
  9. Validate the totals against the source data.

Important: The availability of cross-database joins depends on the connector combination and other limitations. Relationships, joins, unions, and data blending have different behaviors. Choose the method that matches the data structure and analytical objective.

Official reference: Plan a Data Source and Combine Tables.


10. Relationships in Tableau

A relationship defines how two tables are related using common fields without immediately merging their rows into a single physical table. Tableau uses the relationship model to determine how to query the data for a particular visualization.

Example

An Excel Products table contains ProductID and ProductName. A SQL Orders table contains OrderID, ProductID, and Sales. The ProductID field can be used to relate the tables.

Excel Products
-------------------------
ProductID | ProductName
P01       | Laptop
P02       | Monitor
P03       | Keyboard

          Relationship
               |
               v

SQL Orders
-------------------------
OrderID | ProductID | Sales
101     | P01       | 50000
102     | P02       | 20000
103     | P01       | 45000

This relationship enables analysis of sales by product name while keeping the tables logically separate.

Advantages of relationships

  • Preserve the separate logical tables.
  • Allow Tableau to determine appropriate joins for the context of a visualization.
  • Can be useful when tables have different levels of detail.
  • Reduce the need to commit to one fixed join structure for every analysis.

When to use relationships

Relationships are generally a good starting point when combining multiple tables in Tableau's data model, particularly when the tables have different levels of detail or when you want Tableau to handle the query structure for each view.

Official documentation: Understand Relationships in Tableau.


11. Joins in Tableau

A join combines tables using matching fields and a selected join type. Unlike a relationship, a join creates a combined table at the physical layer of the data model.

11.1 Inner join

An inner join returns rows with matching keys in both tables.

SELECT *
FROM Orders
INNER JOIN Customers
ON Orders.CustomerID = Customers.CustomerID;

Example: Only orders with a matching customer record are returned.

11.2 Left join

A left join keeps all rows from the left table and adds matching information from the right table. Where there is no match, right-side fields are NULL.

SELECT *
FROM Orders
LEFT JOIN Customers
ON Orders.CustomerID = Customers.CustomerID;

Example: All orders are retained, including orders whose customer record is missing.

11.3 Right join

A right join keeps all rows from the right table and adds matching information from the left table.

SELECT *
FROM Orders
RIGHT JOIN Customers
ON Orders.CustomerID = Customers.CustomerID;

11.4 Full outer join

A full outer join retains matched rows and unmatched rows from both tables, where the database and connector support it.

SELECT *
FROM Orders
FULL OUTER JOIN Customers
ON Orders.CustomerID = Customers.CustomerID;

Join comparison

Join Type Rows Retained Common Use
Inner Matching rows only Analyze records that have matches in both tables.
Left All left rows and matching right rows Retain every order even if customer details are missing.
Right All right rows and matching left rows Retain every customer even if no order exists.
Full outer All rows from both sides Identify matches and unmatched records across datasets.

Creating a join in Tableau

  1. Connect to the relevant data source or sources.
  2. Place a table on the data model canvas.
  3. Open the physical join canvas as appropriate.
  4. Add the second table.
  5. Select the join icon.
  6. Choose the join type.
  7. Select the matching fields and join operator.
  8. Review the resulting data preview.
  9. Check row counts, NULL values, and aggregate totals.

Common join mistakes

  • Joining fields that represent different concepts.
  • Joining text fields to incompatible numeric fields.
  • Using non-unique keys where a one-to-one relationship was expected.
  • Multiplying sales values because multiple matching rows exist on both sides.
  • Removing unmatched records unintentionally with an inner join.

Official documentation: Join Your Data in Tableau.


12. Unions in Tableau

A union appends rows from one table to another. It is useful when two or more tables contain similar columns and represent the same type of information across different periods, locations, or departments.

Example

Suppose a company stores sales for January and February in separate Excel worksheets. Both sheets contain OrderID, OrderDate, Product, Region, and Sales. A union combines the records vertically.

January Sales
OrderID | Product | Sales
101     | Laptop  | 50000
102     | Monitor | 20000

February Sales
OrderID | Product | Sales
103     | Laptop  | 45000
104     | Keyboard| 7500

Union Result
OrderID | Product  | Sales
101     | Laptop   | 50000
102     | Monitor  | 20000
103     | Laptop   | 45000
104     | Keyboard | 7500

When to use a union

  • Combining monthly sales files with the same structure.
  • Appending records from different branches.
  • Combining annual data files.
  • Appending similar transaction tables from different departments.

A union is different from a join: a union adds rows vertically, whereas a join generally adds columns horizontally by matching records.


13. Data Blending

Data blending combines data from separate data sources at the visualization level. Tableau queries the sources independently and combines the aggregated results using linked fields.

Example

Suppose sales data comes from SQL Server and budget data comes from an independent Excel source. Data blending may be useful when the sources need to remain separate and a suitable relationship or join is not available for the required analysis.

Important points

  • One data source acts as the primary source for a worksheet, while other sources are secondary.
  • Linking fields determine how the aggregated results are combined.
  • Blending does not simply create one physical joined table.
  • Aggregation levels and missing links can affect the resulting values.
  • Relationships are generally the recommended starting point for many multi-table data models, while blending remains useful in specific scenarios.

14. Introduction to SQL Queries for Tableau Users

SQL queries allow users to retrieve, filter, aggregate, and organize database information. Tableau can analyze database tables directly, and supported connectors may also allow users to use a Custom SQL query when a specific result set is needed.

14.1 SELECT statement

The SELECT statement retrieves specified columns from a table.

SELECT OrderID, Region, SalesAmount
FROM Orders;

This query returns the OrderID, Region, and SalesAmount columns from the Orders table.

14.2 WHERE clause

The WHERE clause filters rows based on a condition.

SELECT *
FROM Orders
WHERE Region = 'Mumbai';

This query returns orders where the Region field equals Mumbai.

14.3 ORDER BY

ORDER BY sorts the query results.

SELECT OrderID, SalesAmount
FROM Orders
ORDER BY SalesAmount DESC;

This query sorts orders from highest sales amount to lowest.

14.4 GROUP BY

GROUP BY groups records so aggregate functions can calculate values for each group.

SELECT Region, SUM(SalesAmount) AS TotalSales
FROM Orders
GROUP BY Region;

This query calculates total sales for each region.

14.5 Aggregate functions

Function Purpose Example
SUM() Adds numeric values. SUM(SalesAmount)
AVG() Calculates an average. AVG(SalesAmount)
COUNT() Counts rows or non-NULL values, depending on expression. COUNT(OrderID)
MIN() Returns the minimum value. MIN(SalesAmount)
MAX() Returns the maximum value. MAX(SalesAmount)

14.6 JOIN query

SELECT
    Orders.OrderID,
    Customers.CustomerName,
    Orders.SalesAmount
FROM Orders
INNER JOIN Customers
    ON Orders.CustomerID = Customers.CustomerID;

This query returns order information with the corresponding customer name for records that have matching customer IDs.

14.7 SQL queries and Tableau

SQL is useful when data must be filtered, aggregated, or combined at the database level. However, a Custom SQL query should be used thoughtfully. Tableau's native data modeling features often provide more flexibility for analysis and optimization than forcing every operation into one fixed SQL statement.

Official documentation: Connect to a Custom SQL Query in Tableau.


15. Using Custom SQL in Tableau

Custom SQL allows users to provide a SQL statement that Tableau uses as a source query, where supported by the connector. It can be helpful when a particular subset or structure of database data is needed.

Example

SELECT
    Region,
    SUM(SalesAmount) AS TotalSales
FROM Orders
WHERE OrderDate >= '2026-01-01'
GROUP BY Region;

This example retrieves aggregated sales by region for orders on or after January 1, 2026. Date literal syntax can vary by database, so adjust the query for the target platform.

General procedure

  1. Connect Tableau to a supported database.
  2. Choose the Custom SQL option where available.
  3. Enter the SQL query.
  4. Validate the query in the target database or Tableau connection interface.
  5. Inspect the returned fields and data types.
  6. Build visualizations using the query result.

Advantages

  • Can retrieve a specific subset of records.
  • Can perform supported aggregations before data reaches Tableau.
  • Can restructure data for particular reporting requirements.
  • Can expose a useful query result as a source for analysis.

Limitations and precautions

  • SQL syntax varies by database.
  • Complex queries may affect performance.
  • Changes to source schemas can break a query.
  • Custom SQL may limit Tableau's ability to optimize the query compared with native modeling in some scenarios.
  • Use approved database access and never embed sensitive credentials in the query.

16. Live Connections and Extracts

Tableau supports different ways to access data. The appropriate choice depends on freshness requirements, data volume, database performance, connectivity, and operational constraints.

16.1 Live connection

A live connection queries the underlying data source as needed. The displayed data reflects source updates subject to query execution, caching, and the behavior of the connected system.

Advantages:

  • Can access current source data without waiting for an extract refresh.
  • Can leverage database processing and security capabilities.
  • May be appropriate when source-side governance or freshness is important.

Considerations:

  • Depends on source availability and network connectivity.
  • Complex queries can put pressure on the database.
  • Performance depends on the source system, query complexity, and workload.

16.2 Extract

An extract is a stored snapshot of data that Tableau can query independently of repeated live queries to the original source. Extracts may need to be refreshed to incorporate new or changed source data.

Advantages:

  • Can improve performance for some analytical workloads.
  • Can reduce repeated querying of a busy source system.
  • Supports scheduled refresh workflows in suitable environments.

Considerations:

  • Data may be out of date between refreshes.
  • Extract size and refresh duration need to be managed.
  • Access to extract files and published content must be secured.

Comparison table

Feature Live Connection Extract
Data access Queries the source as needed. Uses stored data.
Freshness Depends on source updates and query behavior. Depends on the last successful refresh.
Source dependency Requires source connectivity for queries. Can analyze stored data between refreshes.
Performance Depends heavily on the source and query. Can be fast for some workloads, but depends on extract design.
Maintenance Connection and source availability must be managed. Refresh schedules, credentials, and storage must be managed.

17. Creating Calculated Fields from Excel and SQL Data

Calculated fields allow Tableau users to create new values from existing fields. They are useful for building business metrics without necessarily modifying the original Excel file or database table.

17.1 Total sales

SUM([Sales])

This expression aggregates the Sales measure across the records included in the view.

17.2 Profit margin

SUM([Profit]) / SUM([Sales])

This calculation returns the aggregate profit divided by aggregate sales. Format the result as a percentage and handle zero or NULL sales values where necessary.

17.3 Sales target variance

SUM([Sales]) - SUM([Sales Target])

This expression calculates the difference between aggregated actual sales and aggregated target values. Confirm that the data model does not duplicate target amounts when multiple sales rows exist for the same region.

17.4 Sales performance percentage

IF SUM([Sales Target]) != 0 THEN
    SUM([Sales]) / SUM([Sales Target])
END

This calculation returns actual sales as a proportion of target sales when the aggregated target is nonzero. Format the result as a percentage.

17.5 Order count

COUNTD([Order ID])

This calculation counts distinct order IDs. Use it when Order ID identifies an order and a dataset may contain multiple rows for one order. If each row represents a unique order, a different count may be appropriate.


18. Building Visualizations with Excel and SQL Data

Once the data is connected and prepared, Tableau can use dimensions and measures to create charts and dashboards.

18.1 Bar chart: Sales by region

  1. Open a worksheet.
  2. Drag Region to Columns.
  3. Drag Sales to Rows.
  4. Choose a bar chart if Tableau has not selected one automatically.
  5. Sort regions by sales if appropriate.
  6. Add labels or tooltips to make the chart easier to interpret.

18.2 Line chart: Monthly sales trend

  1. Drag Order Date to Columns.
  2. Choose the appropriate month-level date option.
  3. Drag Sales to Rows.
  4. Choose a line chart.
  5. Review the date range and check for missing periods.

18.3 Text table: Sales by product

  1. Drag Product to Rows.
  2. Drag Sales to Text on the Marks card or use an appropriate table layout.
  3. Add Profit or Quantity if required.
  4. Sort by sales and format the numbers.

18.4 Actual vs. target chart

  1. Use the related sales and target data.
  2. Place Region in the view.
  3. Display actual sales and sales targets as separate measures.
  4. Validate that the target values are aggregated at the intended level.
  5. Choose a side-by-side bar chart or another appropriate comparison view.

18.5 Suggested dashboard layout

---------------------------------------------------
|       SALES PERFORMANCE DASHBOARD               |
---------------------------------------------------
| Total Sales | Total Profit | Orders | Margin     |
---------------------------------------------------
| Sales by Region       | Monthly Sales Trend      |
---------------------------------------------------
| Product Performance   | Actual vs. Target        |
---------------------------------------------------
| Filters: Date | Region | Product | Customer      |
---------------------------------------------------

19. Practical Project: Excel and SQL Sales Analysis

Project title: Retail Sales Performance Dashboard

Objective: Connect Tableau to SQL sales data and an Excel sales-target workbook, combine the information correctly, and build an interactive dashboard.

19.1 Business requirement

A retail company wants to monitor revenue, profit, order volume, and performance against targets. Transaction data is stored in SQL Server, while sales targets are maintained in Excel.

19.2 SQL sales data

Order ID Region Product Sales Profit
1001 Mumbai Laptop 90000 12000
1002 Delhi Monitor 45000 7000
1003 Pune Keyboard 7500 1500
1004 Mumbai Laptop 45000 6000
1005 Delhi Keyboard 10000 1800

19.3 Excel sales targets

Region Sales Target
Mumbai 150000
Delhi 70000
Pune 30000

19.4 Project steps

  1. Connect Tableau to the SQL sales database.
  2. Select the relevant sales table or view.
  3. Add an Excel connection to the workbook containing sales targets.
  4. Inspect the field names, data types, and key values.
  5. Relate the two tables using Region or another appropriate business key.
  6. Check that each region's target is represented at the intended level of detail.
  7. Create calculated fields for total sales, profit margin, target variance, and target attainment.
  8. Create worksheets for sales by region, sales by product, and monthly sales trends if dates are available.
  9. Create an actual-versus-target comparison.
  10. Combine the worksheets into an interactive dashboard.
  11. Add filters for date, region, and product where appropriate.
  12. Validate totals against the SQL source and Excel targets.
  13. Publish the workbook with suitable permissions and connection settings.

19.5 Important validation task

Suppose the Mumbai target is 150000 and the SQL data contains two Mumbai sales records of 90000 and 45000. Actual Mumbai sales equal 135000. Target attainment is 90%.

Actual Sales = 90000 + 45000
             = 135000

Target = 150000

Target Attainment = 135000 / 150000
                  = 0.90
                  = 90%

If the target is repeated once for every sales record after a join, the aggregated target may become incorrect. Prefer a suitable relationship or a data model that preserves the correct level of detail, and verify the results before publishing.


20. Troubleshooting Common Problems

Problem Possible Cause Solution
Excel file does not connect Unsupported format, unavailable file, or access issue. Verify the file extension, location, permissions, and supported connector.
SQL connection fails Incorrect server, database, credentials, driver, or network access. Check connection details, authentication, drivers, and network rules.
Fields have incorrect types Mixed values or inconsistent formatting. Clean the source and set the appropriate Tableau data type.
Dates display incorrectly Dates are stored as text or use inconsistent formats. Standardize the dates and confirm Tableau recognizes the intended date type.
Some records disappear Join type, filters, NULL keys, or unmatched records. Inspect joins, relationships, filters, and unmatched keys.
Sales totals are too high Duplicate rows caused by joins or multiple matching keys. Review the data grain, join keys, relationships, and aggregation.
Target values are repeated Targets are joined to detailed sales records. Model the target at its correct level of detail and validate aggregation.
Dashboard loads slowly Large source data, complex queries, or inefficient calculations. Measure performance, simplify the model, and optimize the source query.
Published workbook cannot access data Credentials, network access, permissions, or refresh settings are incorrect. Review the published connection configuration and data-source permissions.
Extract is outdated Refresh has not run or failed. Check refresh history, credentials, and scheduling configuration.

21. Best Practices for Working with Excel and SQL Data

  • Plan the data model: Understand how tables relate before building dashboards.
  • Use meaningful field names: Replace unclear names with descriptive business terminology when appropriate.
  • Validate data types: Ensure dates, numbers, text, and identifiers are interpreted correctly.
  • Choose the right modeling method: Use relationships as a sensible starting point for multi-table analysis; use joins, unions, or blending when they better fit the use case.
  • Avoid unnecessary duplication: Check uniqueness and table granularity before joining data.
  • Keep data clean: Resolve inconsistent values and invalid records where appropriate.
  • Use SQL thoughtfully: Filter or aggregate at the source when useful, but avoid unnecessary query complexity.
  • Choose live or extract deliberately: Consider freshness, source performance, and maintenance requirements.
  • Secure credentials: Follow the organization's database access and credential policies.
  • Validate calculations: Compare dashboard totals with the original source data.
  • Document data sources: Record field meanings, refresh schedules, ownership, and connection dependencies.
  • Test published content: Verify that the workbook works with the actual permissions and connection settings of its intended users.

22. Interview Questions and Answers

Q1. What is the difference between Excel and SQL data?

Answer: Excel stores information in workbooks and worksheets, while SQL databases store structured records in database tables. Excel is often used for spreadsheet-based reporting and smaller datasets, whereas SQL databases commonly support centralized, multi-user applications and larger data systems.

Q2. How do you connect Excel to Tableau?

Answer: Open Tableau Desktop, select Microsoft Excel under Connect, choose the workbook, select the required worksheet or table, validate the data, and create visualizations.

Q3. How do you connect Tableau to SQL Server?

Answer: Select the SQL Server connector, enter the server and database details, authenticate using the approved method, select the relevant tables or views, and validate the resulting data source.

Q4. What is the difference between a relationship and a join?

Answer: A relationship defines how logical tables are related while preserving their separate structure. A join combines tables into a physical table using matching fields and a specified join type.

Q5. What is the difference between a join and a union?

Answer: A join combines data horizontally by matching rows using fields. A union appends data vertically by adding rows from tables with compatible structures.

Q6. What is data blending?

Answer: Data blending combines results from separate data sources at the visualization level using linked fields, rather than creating a single physical joined table.

Q7. What is a live connection?

Answer: A live connection queries the underlying data source as needed. Data freshness and performance depend on the source, query execution, and caching behavior.

Q8. What is an extract?

Answer: An extract is a stored snapshot of data that Tableau can query. It needs to be refreshed to incorporate later source changes.

Q9. What is Custom SQL?

Answer: Custom SQL allows a user to provide a SQL query as the source for analysis where the connector supports it. It can filter, aggregate, or restructure database data.

Q10. Why are data types important?

Answer: Correct data types ensure that Tableau interprets values properly for calculations, filters, date analysis, sorting, and joins.

Q11. Why can a join produce incorrect sales totals?

Answer: A join may duplicate fact rows when the join keys are not unique or when the tables have different levels of detail. Validate key uniqueness, row counts, and aggregates.

Q12. When should you use a union?

Answer: Use a union when appending records from tables that contain similar fields, such as monthly sales files with the same structure.

Q13. How can you compare actual sales with an Excel target?

Answer: Connect to the SQL sales data and Excel target table, relate them using a suitable key, create actual-versus-target calculations, and verify that the target values are not duplicated during aggregation.

Q14. What causes a SQL connection failure?

Answer: Common causes include an incorrect server or database name, invalid credentials, missing drivers, network restrictions, and insufficient database permissions.

Q15. How can you improve Tableau performance with SQL data?

Answer: Review source query performance, reduce unnecessary fields and records, optimize the data model, simplify calculations, and compare live connections with extracts where appropriate.


23. Practice Exercises

  1. Connect Tableau to an Excel sales workbook and create a bar chart of sales by region.
  2. Connect Tableau to a supported SQL database and create a monthly sales trend.
  3. Change an incorrectly interpreted field to the correct data type and verify the result.
  4. Create a calculated field for profit margin.
  5. Build a relationship between an Orders table and a Products table using ProductID.
  6. Create an inner join and a left join and compare the resulting records.
  7. Union two monthly Excel datasets with compatible columns.
  8. Combine SQL sales data with Excel sales targets and create an actual-versus-target chart.
  9. Write a SQL query that returns total sales by region.
  10. Investigate a dataset in which sales totals increase unexpectedly after a join.

24. Quick Revision Checklist

  • Excel stores data in workbooks, worksheets, tables, and named ranges.
  • SQL databases store structured records in tables and views.
  • Tableau supports Excel connections and many database connectors.
  • Data types affect calculations, joins, filters, and visualization behavior.
  • Data cleaning helps prevent misleading analysis.
  • Relationships define how logical tables are related.
  • Joins combine matching records into a physical table.
  • Unions append rows from compatible tables.
  • Data blending combines aggregated results from separate sources.
  • Custom SQL can provide a tailored query result when supported.
  • Live connections query the source; extracts use stored snapshots.
  • Calculated fields create new analytical measures and dimensions.
  • Always validate totals after combining data.
  • Protect database credentials and configure published access correctly.
  • Choose a data model that preserves the intended level of detail.

25. Official Tableau Learning Resources


26. Conclusion

Working with Excel and SQL data is a fundamental Tableau skill. Excel provides a convenient way to work with spreadsheet-based information, while SQL databases offer structured, centralized access to business records. Tableau can connect to both sources and use relationships, joins, unions, data blending, calculations, and visualizations to create meaningful business reports.

The most important skills are connecting correctly, preparing clean data, choosing the appropriate data model, writing basic SQL queries, selecting live connections or extracts thoughtfully, and validating the accuracy of the results. By applying these practices, you can build reliable dashboards that help organizations understand sales, profitability, customer behavior, and business performance.

Explore the course: Explore Tableau Training

Register for a demo: Register for a Tableau Course Demo

whatsapp